package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.entity.system.SysUser;
import com.ruoyi.common.util.Result;
import com.ruoyi.common.util.page.PageUtils;
import com.ruoyi.common.util.page.Query;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户 业务层处理
 * 
 * @author LiuXiaoYu
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper,SysUser> implements ISysUserService {

   @Autowired
   private SysUserMapper sysUserMapper;

   /**
    * 根据当前用户的数据权限信息查看所有用户
    * @param sysUser
    * @return
    */
   @Override
   @DataScope(deptAlias = "d",userAlias = "u")
   public PageUtils getUserList(SysUser sysUser,Page page) {
      IPage<SysUser> sysUserPage =sysUserMapper.selectUserList(page, sysUser);
      return new PageUtils(sysUserPage );
   }

   /**
    * 添加用户
    * @param sysUser
    * @return
    */
   @Override
   @Transactional(rollbackFor = Exception.class)
   public int insertUser(SysUser sysUser) {
      return sysUserMapper.insert(sysUser);
   }

}
